<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link type="text/css" rel="stylesheet" href="layui/css/layui.css"/>
		<script type="text/javascript" src="layui/layui.js"></script>
	</head>
	<body>
		<form id="updateGuestbook" class="layui-form" action="">
		    <div class="layui-form-item">
				<label class="layui-form-label"><span style="color: red;">*</span>id:</label>
				<div class="layui-input-inline">
					<input  type="text" id="id" placeholder="请输入id"
						lay-verify = "required" readonly="readonly" name="id" class="layui-input layui-bg-gray">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><span style="color: red;">*</span>留言:</label>
				<div class="layui-input-inline">
				    <textarea name="comtent" id="comtent" readonly="readonly" style="width:350px;height:100px"></textarea>
					<%--<input  type="text" id="comtent" placeholder="请输入id"
						lay-verify = "required" readonly="readonly" name="comtent" class="layui-input layui-bg-gray">--%>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">
					<span style="color: red;">*</span>处理内容:</label>
				<div class="layui-input-inline">
				    <textarea name="responses" id="responses" style="width:350px;height:100px"></textarea>
					<%--<input  type="text" id="responses" name="responses" placeholder="请输入内容"
						lay-verify = "required" class="layui-input"/>--%>
				</div>
			</div>
			
			
			<div class="layui-form-item">
				<div class="layui-input-block">
				<button class="layui-btn layui-btn-sm" lay-submit lay-filter="updateGuestbook">处理</button>
				<button type="reset" lay-submit class="layui-btn layui-btn-sm">取消</button>
				</div>
			</div>
		</form>
		
		<script>
			layui.use(['form','layer','upload'],function(){
				var form = layui.form,$ = layui.$,layer = layui.layer,upload = layui.upload;
				
				
				// 表单按钮在监听的时候    updateUser按钮后面的（lay-filter事件名字）
					form.on('submit(updateGuestbook)',function(res){
						var str = $("#updateGuestbook").serialize();
						$.post(
							"http://localhost:8080/Dream/GuestbookAdminServlet?req=GuestbookUpdate",
							str,
							function(res){
							   //success: true，操作成功；false,操作失败 
							   if(res.success == true){
							   	 layer.alert("处理成功");
							   	 //先得到当前iframe层的索引
								var index = parent.layer.getFrameIndex(window.name); 
								//再执行关闭 
								parent.layer.close(index);  
								//关闭父级页面的表格
								parent.layui.table.reload('table');
							   }else{
							   	layer.alert("处理失败");
							   }
							},
							"json"
						);
						return false;
						
					});
				
			})
			
		</script>
		
	</body>
</html>
